home *** CD-ROM | disk | FTP | other *** search
- Subject: v20i032: Command-line editor with predictions, Part04/04
- Newsgroups: comp.sources.unix
- Sender: sources
- Approved: rsalz@uunet.UU.NET
-
- Submitted-by: Mark James <jamesm@cpsc.UCalgary.CA>
- Posting-number: Volume 20, Issue 32
- Archive-name: reactivekbd/part04
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 4 (of 4)."
- # Contents: functions.c
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'functions.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'functions.c'\"
- else
- echo shar: Extracting \"'functions.c'\" \(35838 characters\)
- sed "s/^X//" >'functions.c' <<'END_OF_FILE'
- X#include "file+rk.h"
- X#include "rk_button.h"
- X#include <sys/ioctl.h>
- X#include <stdio.h>
- X
- Xextern char *cursor_left, *cursor_right;
- Xextern char *enter_insert_mode, *exit_insert_mode;
- Xextern char *pre_insert_char, *post_insert_char;
- Xextern char *enter_delete_mode, *exit_delete_mode, *delete_a_char;
- Xextern char *clear_screen;
- Xextern char *enter_standout_mode, *exit_standout_mode; /* JJD 9-86 */
- Xextern int current_key_map;
- Xextern char meta_prefixes[MAXEXTENSIONS][MAXEXTENSIONS];
- Xextern int meta_map[MAXEXTENSIONS][MAXEXTENSIONS];
- X
- Xextern pred_number;
- Xextern pty_master;
- Xextern char output_string[],temp_str[];
- Xextern output_string_length;
- Xextern char pred_mode,pred_on_display,lisp_mode,nl_truncate_mode,eol_only_mode,eol_longer_mode,add_space_mode,show_eol_mode;
- Xextern char pred_buff[];
- Xextern (*keymap[128][MAXEXTENSIONS]) ();
- Xextern char trace_mode;
- Xextern struct sgttyb new_stdin, old_stdin;
- Xextern int maxk;
- Xextern int maxprime;
- Xextern max_freq;
- Xextern max_nodes;
- X
- Xappend_to_output_string(c)
- X char c;
- X{
- X output_string[output_string_length++] = c;
- X}
- X
- Xint
- Xaccept_forward_word(e)
- X ED_STRUCT *e;
- X{ /* JJD 9-86 */
- X char *ch;
- X int how_many, num_to_advance;
- X
- X if (!pred_mode)
- X return forward_word(e);
- X how_many = e->universal_argument;
- X num_to_advance = 0;
- X /* truncate prediction to after first NL */
- X if (ch = index(pred_buff, '\n'))
- X *(++ch) = '\0';
- X ch = &pred_buff[0]; /* changed from editor data */
- X
- X while (how_many--) {
- X if ((!isalnum(*ch)) && (*ch != '-') && (*ch != '_'))
- X while (*ch && (!isalnum(*ch)) && (*ch != '-') && (*ch != '_'))
- X num_to_advance++, ch++;
- X
- X while (*ch && (isalnum(*ch) || (*ch == '-') || (*ch == '_')))
- X num_to_advance++, ch++;
- X if(isspace(*ch)&&add_space_mode&&(*ch!='\n'))
- X num_to_advance++, ch++;
- X if (*ch == '\0')
- X how_many = 0;
- X }
- X
- X e->universal_argument = num_to_advance;
- X return accept_forward_char(e);
- X}
- X
- Xint BOGUS(e)
- X ED_STRUCT *e;
- X{
- X e->universal_argument = 1;
- X write (1, "\07", 1);
- X return(OK);
- X}
- X
- Xint
- Xforward_word(e)
- X ED_STRUCT *e;
- X{
- X
- X char *ch;
- X int how_many, num_to_advance;
- X
- X how_many = e->universal_argument;
- X num_to_advance = 0;
- X ch = e->dot;
- X
- X while (how_many--) {
- X if ((!isalnum(*ch)) && (*ch != '-') && (*ch != '_'))
- X while (*ch && (!isalnum(*ch)) && (*ch != '-') && (*ch != '_'))
- X num_to_advance++, ch++;
- X
- X while (*ch && (isalnum(*ch) || (*ch == '-') || (*ch == '_')))
- X num_to_advance++, ch++;
- X
- X if (*ch == '\0')
- X how_many = 0;
- X }
- X
- X e->universal_argument = num_to_advance;
- X return forward_char(e);
- X}
- X
- X
- Xint
- Xbackward_word(e)
- X ED_STRUCT *e;
- X{
- X
- X char *ch, *cb;
- X int num_to_go, how_many;
- X
- X cb = e->current_buffer;
- X ch = e->dot;
- X num_to_go = 0;
- X how_many = e->universal_argument;
- X
- X if (ch-- == cb)
- X return OK;
- X
- X while (how_many--) {
- X while ((ch >= cb) && (!isalnum(*ch)) && (*ch != '-') && (*ch != '_'))
- X num_to_go++, ch--;
- X
- X while ((ch >= cb) &&
- X (isalnum(*ch) ||
- X (*ch == '-') ||
- X (*ch == '_')))
- X num_to_go++, ch--;
- X
- X if (ch < e->current_buffer)
- X how_many = 0;
- X }
- X
- X e->universal_argument = num_to_go;
- X return backward_char(e);
- X}
- X
- X
- Xint
- Xdelete_word(e)
- X ED_STRUCT *e;
- X{
- X
- X char *ch;
- X int how_many, num_to_advance;
- X
- X how_many = e->universal_argument;
- X num_to_advance = 0;
- X ch = e->dot;
- X
- X while (how_many--) {
- X if ((!isalnum(*ch)) && (*ch != '-') && (*ch != '_'))
- X while (*ch && (!isalnum(*ch)) && (*ch != '-') && (*ch != '_'))
- X num_to_advance++, ch++;
- X
- X while (*ch && (isalnum(*ch) || (*ch == '-') || (*ch == '_')))
- X num_to_advance++, ch++;
- X
- X if (*ch == '\0')
- X how_many = 0;
- X }
- X
- X e->universal_argument = num_to_advance;
- X return delete_char(e);
- X}
- X
- X
- Xint
- Xbackspace_word(e)
- X ED_STRUCT *e;
- X{
- X
- X char *ch, *cb;
- X int num_to_go, how_many;
- X
- X cb = e->current_buffer;
- X ch = e->dot;
- X num_to_go = 0;
- X how_many = e->universal_argument;
- X
- X if (ch-- == cb)
- X return OK;
- X
- X while (how_many--) {
- X while ((ch >= cb) && (!isalnum(*ch)) && (*ch != '-') && (*ch != '_'))
- X num_to_go++, ch--;
- X
- X while ((ch >= cb) &&
- X (isalnum(*ch) ||
- X (*ch == '-') ||
- X (*ch == '_')))
- X num_to_go++, ch--;
- X
- X if (ch < e->current_buffer)
- X how_many = 0;
- X }
- X
- X e->universal_argument = num_to_go;
- X return backspace_char(e);
- X}
- X
- X
- Xint
- Xforward_paren(e)
- X ED_STRUCT *e;
- X{
- X
- X char *ch = e->dot - 1; /* pretend to go back one */
- X int paren_count = 1;
- X int num_to_advance = 0;
- X
- X while (*++ch && paren_count) {
- X num_to_advance++;
- X if (*ch == ')')
- X paren_count--; /* a ')' with no intervening ()'s */
- X else if (*ch == '(') /* search for ) matching this ( */
- X while (*++ch && paren_count) {
- X num_to_advance++;
- X if (*ch == ')')
- X paren_count--;
- X else if (*ch == '(')
- X paren_count++;
- X }
- X }
- X
- X e->universal_argument = num_to_advance;
- X return forward_char(e);
- X}
- X
- X
- Xint
- Xbackward_paren(e)
- X ED_STRUCT *e;
- X{
- X
- X char *ch, *cb;
- X int paren_count = 1;
- X int num_to_go = 0;
- X
- X ch = e->dot;
- X cb = e->current_buffer;
- X
- X if (ch != cb) /* not already at the beginning */
- X while ((--ch >= cb) && paren_count) {
- X num_to_go++;
- X if (*ch == '(')
- X paren_count--; /* a '(' with no intervening
- X * ()'s */
- X else if (*ch == ')') /* search for ( matching this
- X * ) */
- X while ((--ch >= cb) && paren_count) {
- X num_to_go++;
- X if (*ch == '(')
- X paren_count--;
- X else if (*ch == ')')
- X paren_count++;
- X }
- X }
- X
- X e->universal_argument = num_to_go;
- X return backward_char(e);
- X}
- X
- Xint
- Xtoggle_lisp_mode(e)
- X ED_STRUCT *e;
- X{
- X lisp_mode = !lisp_mode;
- X return OK;
- X}
- X
- Xint
- Xtoggle_add_space_mode(e)
- X ED_STRUCT *e;
- X{
- X add_space_mode = !add_space_mode;
- X return OK;
- X}
- X
- Xint
- Xtoggle_show_eol_mode(e)
- X ED_STRUCT *e;
- X{
- X show_eol_mode = !show_eol_mode;
- X if (pred_on_display)
- X erase_pred_buffer(e);
- X if (pred_mode)
- X make_a_prediction(pred_buff);
- X return OK;
- X}
- X
- Xint
- Xtoggle_nl_truncate_mode(e)
- X ED_STRUCT *e;
- X{ /* JJD 9-86 */
- X nl_truncate_mode = !nl_truncate_mode;
- X if (pred_on_display)
- X erase_pred_buffer(e);
- X if (pred_mode)
- X make_a_prediction(pred_buff);
- X return OK;
- X}
- X
- Xint
- Xtoggle_eol_only_mode(e)
- X ED_STRUCT *e;
- X{ /* JJD 9-86 */
- X eol_only_mode = !eol_only_mode;
- X if (pred_on_display)
- X erase_pred_buffer(e);
- X if (pred_mode)
- X make_a_prediction(pred_buff);
- X return OK;
- X}
- X
- Xint
- Xtoggle_eol_longer_mode(e)
- X ED_STRUCT *e;
- X{ /* JJD 9-86 */
- X eol_longer_mode = !eol_longer_mode;
- X if (pred_on_display)
- X erase_pred_buffer(e);
- X if (pred_mode)
- X make_a_prediction(pred_buff);
- X return OK;
- X}
- X
- Xint
- Xtoggle_pred_mode(e)
- X ED_STRUCT *e;
- X{ /* JJD 9-86 */
- X pred_mode = !pred_mode;
- X if (pred_on_display)
- X erase_pred_buffer(e);
- X if (pred_mode)
- X make_a_prediction(pred_buff);
- X return OK;
- X}
- X
- Xint
- Xshow_free_nodes(e)
- X ED_STRUCT *e;
- X{ /* JJD 1-87, revised 3-89 */
- X extern int next_free;
- X char tbuf[128]; /* extern in rk_button */
- X extern long psize;
- X sprintf(tbuf, "\015\nK=%d, COUNT=%d, NODES=%d, PRIME=%d; psize=%d, nodes=%d\015\n",
- X maxk, max_freq, max_nodes, maxprime, psize, next_free);
- X write(1, tbuf, strlen(tbuf));
- X write(1, "Continue: ", 10); /* JJD 3-89 added */
- X draw_current_edit_line(e); /* JJD 3-89 added */
- X return OK;
- X}
- X
- Xint
- Xshow_version(e)
- X ED_STRUCT *e;
- X{ /* JJD 3-89 added */
- X char tbuf[128];
- X sprintf(tbuf, "\015\nRK_Button Version: %s", RK_VERSION);
- X strcat(tbuf, ", with file_completion (^C).\015\n");
- X write(1, tbuf, strlen(tbuf));
- X write(1, "Continue: ", 10);
- X draw_current_edit_line(e);
- X return OK;
- X}
- X
- Xint
- Xprime_from_file(e)
- X ED_STRUCT *e;
- X{ /* JJD 9-86 */
- X char filename[256];
- X FILE *from;
- X int i;
- X char c;
- X extern Buffer Buf; /* externs in rk_button */
- X extern char context[MAX_CMD_LINE_LENGTH];
- X
- X erase_current_edit_line(e);
- X e->dot = e->current_buffer;
- X e->mark = e->current_buffer;
- X *(e->dot) = '\0';
- X
- X ioctl(0, TIOCGETP, &new_stdin);
- X ioctl(0, TIOCSETP, &old_stdin);
- X strcpy(filename, "");
- X printf("File to prime from ([RETURN] to cancel): ");
- X fflush(stdout);
- X gets(filename);
- X if (filename[0] == '\0') {
- X printf("Command cancelled.\r\n");
- X fflush(stdout);
- X } else {
- X if ((from = fopen(filename, "r")) == NULL) {
- X printf("cannot open: %s\r\n", filename);
- X fflush(stdout);
- X } else {
- X while (((int) (c = getc(from))) != EOF)
- X for (i = maxk; i > 0; i--)
- X Buf[i] = move_up(Buf[i - 1], c);
- X fclose(from);
- X show_free_nodes(e);
- X }
- X }
- X ioctl(0, TIOCSETP, &new_stdin);
- X
- X return OK;
- X}
- X
- X
- Xint
- Xclose_paren(e)
- X ED_STRUCT *e;
- X{
- X
- X char *old_dot;
- X
- X if (!lisp_mode)
- X return self_insert(e);
- X
- X old_dot = e->dot;
- X if (*old_dot != ')') /* if not on a ')', insert one */
- X self_insert(e);
- X
- X forward_char(e); /* skip past ')' so bkd-prn works */
- X backward_paren(e); /* flash back to matching '(' */
- X sleep(1);
- X
- X e->universal_argument = 1 + old_dot - e->dot;
- X return forward_char(e); /* skip ahead to old dot + 1 */
- X}
- X
- X
- Xint
- Xopen_paren(e)
- X ED_STRUCT *e;
- X{
- X
- X char *old_dot;
- X
- X self_insert(e); /* stick in an open_paren */
- X if (!lisp_mode)
- X return OK;
- X
- X old_dot = e->dot;
- X if ((*old_dot == ')') || (*old_dot == 0)) {
- X e->current_input_char = ')'; /* if on a ')' or at the end */
- X self_insert(e); /* then insert matching ')' */
- X backward_char(e); /* and go back inside () */
- X }
- X return OK;
- X}
- X
- X
- Xint
- Xincrement_universal_argument(e)
- X ED_STRUCT *e;
- X{
- X
- X if (e->universal_argument > UNIVERSAL_ARGUMENT_MAXIMUM)
- X write(1, "\07", 1);
- X else
- X e->universal_argument *= 4;
- X
- X return OK;
- X}
- X
- X
- Xint
- Xclear_display(e)
- X ED_STRUCT *e;
- X{
- X
- X e->universal_argument = 1;
- X output_string_length = 0;
- X if (clear_screen) {
- X tputs(clear_screen, ONE_LINE, append_to_output_string);
- X write(1, output_string, output_string_length);
- X } else
- X write(1, "\r\n\r\n", 2);
- X draw_current_edit_line(e);
- X
- X return OK;
- X}
- X
- X
- X
- Xint
- Xprevious_line(e)
- X ED_STRUCT *e;
- X{
- X
- X int how_many;
- X
- X how_many = e->universal_argument;
- X e->current_ed_buff_ptr->dot = e->dot;
- X e->current_ed_buff_ptr->mark = e->mark;
- X erase_current_edit_line(e);
- X for (; how_many; --how_many)
- X e->current_ed_buff_ptr = e->current_ed_buff_ptr->prev_ptr;
- X e->current_buffer = e->current_ed_buff_ptr->string;
- X e->dot = e->current_ed_buff_ptr->dot;
- X e->mark = e->current_ed_buff_ptr->mark;
- X draw_current_edit_line(e);
- X e->universal_argument = 1;
- X return OK;
- X}
- X
- X
- Xint
- Xprevious_pred(e)
- X ED_STRUCT *e;
- X{ /* JJD 9-86 */
- X
- X if (pred_number)
- X pred_number--;
- X return OK;
- X}
- X
- Xint
- Xnext_pred(e)
- X ED_STRUCT *e;
- X{ /* JJD 9-86 */
- X
- X if (++pred_number > 127)
- X pred_number = 127;
- X return OK;
- X}
- X
- Xint
- Xnext_line(e)
- X ED_STRUCT *e;
- X{
- X
- X int how_many;
- X
- X how_many = e->universal_argument;
- X e->current_ed_buff_ptr->dot = e->dot;
- X
- X e->current_ed_buff_ptr->mark = e->mark;
- X
- X erase_current_edit_line(e);
- X for (; how_many; --how_many)
- X e->current_ed_buff_ptr = e->current_ed_buff_ptr->next_ptr;
- X e->current_buffer = e->current_ed_buff_ptr->string;
- X e->dot = e->current_ed_buff_ptr->dot;
- X
- X e->mark = e->current_ed_buff_ptr->mark;
- X
- X draw_current_edit_line(e);
- X e->universal_argument = 1;
- X return OK;
- X}
- X
- X
- Xint
- Xdiscard_current_edit_line(e)
- X ED_STRUCT *e;
- X{
- X
- X strcpy(e->kill_buffer, e->current_buffer);
- X erase_current_edit_line(e);
- X e->dot = e->current_buffer;
- X
- X e->mark = e->current_buffer;
- X
- X *e->dot = '\0';
- X
- X return OK;
- X}
- X
- X
- Xint
- Xdiscard_rest_of_line(e)
- X ED_STRUCT *e;
- X{
- X
- X strcpy(e->kill_buffer, e->dot);
- X e->universal_argument = strlen(e->dot);
- X
- X if (e->universal_argument == 0) {
- X e->universal_argument = 1;
- X return OK;
- X } else
- X
- X {
- X if (e->mark > e->dot)
- X e->mark = e->dot;
- X return delete_char(e);
- X }
- X
- X}
- X
- X
- Xint
- Xyank_from_kill_buffer(e)
- X ED_STRUCT *e;
- X{
- X
- X int count;
- X
- X output_string_length = 0;
- X strcpy(temp_str, e->dot);
- X strcpy(e->dot, e->kill_buffer);
- X
- X if (e->mark > e->dot)
- X e->mark += strlen(e->kill_buffer);
- X
- X e->dot = e->dot + strlen(e->kill_buffer);
- X strcpy(e->dot, temp_str);
- X display_string_into_output_string(e->kill_buffer);
- X count = display_string_into_output_string(temp_str);
- X for (; count; --count)
- X tputs(cursor_left, ONE_LINE, append_to_output_string);
- X write(1, output_string, output_string_length);
- X
- X return OK;
- X}
- X
- X
- X
- Xint
- Xdisplay_pred_buffer(e)
- X ED_STRUCT *e;
- X{ /* JJD 9-86 ???? */
- X
- X int count;
- X
- X output_string[0] = '\0';
- X output_string_length = 0;
- X
- X if (enter_standout_mode)
- X tputs(enter_standout_mode, ONE_LINE, append_to_output_string);
- X count = display_string_into_output_string(pred_buff);
- X if (enter_standout_mode)
- X tputs(exit_standout_mode, ONE_LINE, append_to_output_string);
- X count += display_string_into_output_string(e->dot);
- X
- X for (; count; --count)
- X tputs(cursor_left, ONE_LINE, append_to_output_string);
- X write(1, output_string, output_string_length);
- X pred_on_display = 1;
- X
- X return OK;
- X}
- X
- X
- Xint
- Xerase_pred_buffer(e)
- X ED_STRUCT *e;
- X{ /* JJD 9-86 */
- X
- X int num_to_erase, count;
- X
- X output_string[0] = '\0';
- X output_string_length = 0;
- X
- X if (enter_standout_mode)
- X tputs(exit_standout_mode, ONE_LINE, append_to_output_string);
- X display_string_into_output_string(e->dot);
- X
- X num_to_erase = get_display_length(pred_buff);
- X for (count = num_to_erase; count; --count)
- X output_string[output_string_length++] = ' ';
- X num_to_erase += get_display_length(e->dot);
- X for (count = num_to_erase; count; --count)
- X tputs(cursor_left, ONE_LINE, append_to_output_string);
- X write(1, output_string, output_string_length);
- X pred_on_display = 0;
- X
- X return OK;
- X}
- X
- Xint
- Xinsert_interrupt_char(e)
- X ED_STRUCT *e;
- X{
- X
- X struct tchars pty_tchars;
- X
- X ioctl(pty_master, TIOCGETC, &pty_tchars);
- X
- X erase_current_edit_line(e);
- X e->dot = e->current_buffer;
- X
- X e->mark = e->current_buffer;
- X
- X *(e->dot++) = pty_tchars.t_intrc;
- X *(e->dot) = '\0';
- X return FINISHED_BUT_DONT_ADD_CTRL_M;
- X}
- X
- Xint
- Xinsert_quit_char(e)
- X ED_STRUCT *e;
- X{
- X
- X struct tchars pty_tchars;
- X
- X ioctl(pty_master, TIOCGETC, &pty_tchars);
- X
- X erase_current_edit_line(e);
- X e->dot = e->current_buffer;
- X e->mark = e->current_buffer;
- X *(e->dot++) = pty_tchars.t_quitc;
- X *(e->dot) = '\0';
- X return FINISHED_BUT_DONT_ADD_CTRL_M;
- X}
- X
- Xint
- Xinsert_stop_char(e)
- X ED_STRUCT *e;
- X{ /* JJD 9-86 */
- X
- X struct tchars pty_tchars;
- X
- X ioctl(pty_master, TIOCGETC, &pty_tchars);
- X
- X erase_current_edit_line(e);
- X e->dot = e->current_buffer;
- X e->mark = e->current_buffer;
- X *(e->dot++) = pty_tchars.t_stopc;
- X *(e->dot) = '\0';
- X return FINISHED_BUT_DONT_ADD_CTRL_M;
- X}
- X
- Xint
- Xinsert_start_char(e)
- X ED_STRUCT *e;
- X{ /* JJD 9-86 */
- X
- X struct tchars pty_tchars;
- X
- X ioctl(pty_master, TIOCGETC, &pty_tchars);
- X
- X erase_current_edit_line(e);
- X e->dot = e->current_buffer;
- X e->mark = e->current_buffer;
- X *(e->dot++) = pty_tchars.t_startc;
- X *(e->dot) = '\0';
- X return FINISHED_BUT_DONT_ADD_CTRL_M;
- X}
- X
- Xint
- Xinsert_eof_char(e)
- X ED_STRUCT *e;
- X{ /* JJD 9-86 */
- X
- X struct tchars pty_tchars;
- X
- X ioctl(pty_master, TIOCGETC, &pty_tchars);
- X
- X erase_current_edit_line(e);
- X e->dot = e->current_buffer;
- X e->mark = e->current_buffer;
- X *(e->dot++) = pty_tchars.t_eofc;
- X *(e->dot) = '\0';
- X return FINISHED_BUT_DONT_ADD_CTRL_M;
- X}
- X
- Xint
- Xinsert_suspend_char(e)
- X ED_STRUCT *e;
- X{
- X
- X struct ltchars pty_ltchars;
- X
- X ioctl(pty_master, TIOCGLTC, &pty_ltchars);
- X
- X erase_current_edit_line(e);
- X e->dot = e->current_buffer;
- X e->mark = e->current_buffer;
- X *(e->dot++) = pty_ltchars.t_suspc;
- X *(e->dot) = '\0';
- X return FINISHED_BUT_DONT_ADD_CTRL_M;
- X}
- X
- X
- X
- Xint
- Xtwiddle_chars(e)
- X ED_STRUCT *e;
- X{
- X
- X char temp_char;
- X int num_to_back_up, count;
- X
- X output_string_length = 0;
- X
- X if (strlen(e->current_buffer) == 0) {
- X *e->dot++ = '\024';
- X *e->dot = '\0';
- X return FINISHED_BUT_DONT_ADD_CTRL_M;
- X } else if ((e->dot - e->current_buffer) < 2)
- X write(1, "\07", 1);
- X else {
- X temp_char = *(e->dot - 1);
- X *(e->dot - 1) = *(e->dot - 2);
- X *(e->dot - 2) = temp_char;
- X num_to_back_up = get_char_display_length(*(e->dot - 2));
- X num_to_back_up += get_char_display_length(*(e->dot - 1));
- X for (count = num_to_back_up; count; --count)
- X tputs(cursor_left, ONE_LINE, append_to_output_string);
- X display_char_into_output_string(*(e->dot - 2));
- X display_char_into_output_string(*(e->dot - 1));
- X write(1, output_string, output_string_length);
- X }
- X
- X e->universal_argument = 1;
- X
- X return OK;
- X}
- X
- Xint
- Xbeginning_of_line(e)
- X ED_STRUCT *e;
- X{
- X
- X e->universal_argument = 1;
- X output_string[0] = '\0';
- X output_string_length = 0;
- X while (e->dot != e->current_buffer) {
- X e->dot--;
- X if ((*(e->dot) < 32) || (*(e->dot) == 127)) {
- X tputs(cursor_left, ONE_LINE, append_to_output_string);
- X tputs(cursor_left, ONE_LINE, append_to_output_string);
- X } else
- X tputs(cursor_left, ONE_LINE, append_to_output_string);
- X }
- X
- X write(1, output_string, output_string_length);
- X
- X return OK;
- X}
- X
- Xint
- Xend_of_line(e)
- X ED_STRUCT *e;
- X{
- X
- X e->universal_argument = 1;
- X output_string[0] = '\0';
- X output_string_length = 0;
- X display_string_into_output_string(e->dot);
- X e->dot = &(e->current_buffer[strlen(e->current_buffer)]);
- X
- X write(1, output_string, output_string_length);
- X
- X return OK;
- X}
- X
- Xint
- Xquote_char(e)
- X ED_STRUCT *e;
- X{
- X
- X char quoted_char;
- X
- X READ(0, "ed_char, 1);
- X quoted_char &= 127;
- X if (quoted_char == '\0') {
- X write(1, "\07", 1);
- X return OK;
- X } else {
- X e->current_input_char = quoted_char;
- X return self_insert(e);
- X }
- X}
- X
- Xmeta_prefix(e)
- X ED_STRUCT *e;
- X{
- X char metad_char;
- X int i=0;
- X int status;
- X
- X if(e==0)
- X abortit("meta_prefix passed a nil pointer, aborting...\n",-1);
- X
- X while((i<MAXEXTENSIONS) && (meta_prefixes[i][current_key_map]) &&
- X (e->current_input_char!=meta_prefixes[i][current_key_map]))
- X i++;
- X if(i==MAXEXTENSIONS)
- X return(BOGUS(e));
- X current_key_map=meta_map[i][current_key_map];
- X
- X if (pred_mode && pred_buff[0] && !pred_on_display)
- X display_pred_buffer(e); /* JJD 9-86 */
- X READ(0, &metad_char, 1);
- X if (pred_on_display) erase_pred_buffer (e); /* JJD 3-89 added */
- X metad_char &= 127; /* clear high bit */
- X e->current_input_char = metad_char;
- X status = (keymap[(int) metad_char][current_key_map])(e);
- X current_key_map=0;
- X return(status);
- X}
- X
- X
- X
- X
- X
- Xint
- Xbackward_char(e)
- X ED_STRUCT *e;
- X{
- X
- X int num_to_go, count, needs_beep;
- X
- X output_string[0] = '\0';
- X output_string_length = 0;
- X
- X if ((e->dot - e->universal_argument) < e->current_buffer)
- X num_to_go = e->dot - e->current_buffer, needs_beep = 1;
- X else
- X num_to_go = e->universal_argument, needs_beep = 0;
- X
- X count = num_to_go;
- X while (count-- > 0) {
- X e->dot--;
- X tputs(cursor_left, ONE_LINE, append_to_output_string);
- X if ((*(e->dot) < 32) || (*(e->dot) == 127))
- X tputs(cursor_left, ONE_LINE, append_to_output_string);
- X }
- X
- X if (needs_beep)
- X output_string[output_string_length++] = '\07';
- X
- X write(1, output_string, output_string_length);
- X
- X e->universal_argument = 1;
- X
- X return OK;
- X}
- X
- Xint
- Xaccept_to_end_of_line(e)
- X ED_STRUCT *e;
- X{ /* JJD 9-86 */
- X
- X char *ptr;
- X
- X if (!pred_mode)
- X return end_of_line(e);
- X /* truncate prediction to after first NL */
- X if (ptr = index(pred_buff, '\n')){
- X *(++ptr) = '\0';
- X }
- X /* only go to end of prediction */
- X e->universal_argument = strlen(pred_buff);
- X return accept_forward_char(e);
- X}
- X
- Xint
- Xaccept_forward_char(e)
- X ED_STRUCT *e;
- X{ /* JJD 9-86 */
- X
- X int num_to_go, count, needs_beep, finished = 0;
- X
- X if (!pred_mode)
- X return forward_char(e);
- X if (pred_buff[0] == '\n')
- X return finish_editing_line(e);
- X output_string[0] = '\0';
- X output_string_length = 0;
- X
- X num_to_go = strlen(pred_buff);
- X if (e->universal_argument > num_to_go) /* to end of prediction */
- X needs_beep = 1;
- X else
- X num_to_go = e->universal_argument, needs_beep = 0;
- X
- X /* there is at most 1 NL at the end of the prediction */
- X if (pred_buff[num_to_go - 1] == '\n') {
- X num_to_go--;
- X finished = 1;
- X }
- X pred_buff[num_to_go] = '\0';
- X display_string_into_output_string(pred_buff);
- X strcat(pred_buff, e->dot);
- X strcpy(e->dot, pred_buff);
- X if (e->mark > e->dot)
- X e->mark += num_to_go;
- X e->dot += num_to_go;
- X count = display_string_into_output_string(e->dot);
- X for (; count; --count)
- X tputs(cursor_left, ONE_LINE, append_to_output_string);
- X
- X if (needs_beep)
- X output_string[output_string_length++] = '\07';
- X write(1, output_string, output_string_length);
- X e->universal_argument = 1;
- X
- X if (finished)
- X return finish_editing_line(e);
- X else
- X return OK;
- X}
- X
- Xint
- Xforward_char(e)
- X ED_STRUCT *e;
- X{
- X
- X int num_to_go, count, needs_beep;
- X
- X output_string[0] = '\0';
- X output_string_length = 0;
- X
- X if (e->universal_argument > strlen(e->dot))
- X num_to_go = strlen(e->dot), needs_beep = 1;
- X else
- X num_to_go = e->universal_argument, needs_beep = 0;
- X
- X count = num_to_go;
- X while (count-- > 0)
- X display_char_into_output_string(*(e->dot++));
- X
- X if (needs_beep)
- X output_string[output_string_length++] = '\07';
- X
- X write(1, output_string, output_string_length);
- X
- X e->universal_argument = 1;
- X
- X return OK;
- X}
- X
- X
- Xint
- Xbackspace_char(e)
- X ED_STRUCT *e;
- X{
- X
- X int rest_of_line_display_length, count;
- X int num_to_delete;
- X char *c, *new_dot;
- X char *old_dot = e->dot; /* JJD 3-89 added */
- X
- X output_string[0] = '\0';
- X output_string_length = 0;
- X
- X if ((e->dot - e->current_buffer) < e->universal_argument)
- X new_dot = e->current_buffer;
- X else
- X new_dot = e->dot - e->universal_argument;
- X
- X num_to_delete = 0;
- X for (c = e->dot - 1; c >= new_dot; --c)
- X if ((*c < 32) || (*c == 127))
- X num_to_delete += 2;
- X else
- X num_to_delete++;
- X
- X if (delete_a_char) {
- X for (count = num_to_delete; count; --count)
- X tputs(cursor_left, ONE_LINE, append_to_output_string);
- X
- X if (enter_delete_mode)
- X tputs(enter_delete_mode, ONE_LINE, append_to_output_string);
- X
- X for (count = num_to_delete; count; --count)
- X tputs(delete_a_char, ONE_LINE, append_to_output_string);
- X
- X if (enter_delete_mode)
- X tputs(exit_delete_mode, ONE_LINE, append_to_output_string);
- X } else {
- X for (count = num_to_delete; count; --count)
- X tputs(cursor_left, ONE_LINE, append_to_output_string);
- X
- X rest_of_line_display_length =
- X display_string_into_output_string(e->dot);
- X
- X for (count = num_to_delete; count; --count)
- X output_string[output_string_length++] = ' ';
- X
- X for (count = num_to_delete + rest_of_line_display_length; count; --count)
- X tputs(cursor_left, ONE_LINE, append_to_output_string);
- X }
- X
- X if (e->dot - e->universal_argument < e->current_buffer)
- X output_string[output_string_length++] = '\07';
- X
- X strcpy(temp_str, e->dot);
- X strcpy(new_dot, temp_str);
- X e->dot = new_dot;
- X if (e->mark >= new_dot)
- X e->mark -= (old_dot - new_dot);
- X e->universal_argument = 1;
- X write(1, output_string, output_string_length);
- X
- X return OK;
- X}
- X
- Xint
- Xdelete_char(e)
- X ED_STRUCT *e;
- X{
- X
- X int count;
- X int num_to_delete, num_to_back_up;
- X char *c, *new_dot;
- X char *old_dot = e->dot; /* JJD 3-89 added */
- X
- X if (*(e->dot) == '\0') {
- X struct tchars pty_tchars;
- X ioctl(pty_master, TIOCGETC, &pty_tchars);
- X erase_pred_buffer(e);
- X erase_current_edit_line(e);
- X *(e->dot++) = pty_tchars.t_eofc;
- X *(e->dot) = '\0';
- X return FINISHED_BUT_DONT_ADD_CTRL_M;
- X }
- X output_string[0] = '\0';
- X output_string_length = 0;
- X
- X if (e->universal_argument > strlen(e->dot))
- X new_dot = e->dot + strlen(e->dot);
- X else
- X new_dot = e->dot + e->universal_argument;
- X
- X num_to_delete = 0;
- X for (c = e->dot; c < new_dot; ++c)
- X if ((*c < 32) || (*c == 127))
- X num_to_delete += 2;
- X else
- X num_to_delete++;
- X
- X if (delete_a_char) {
- X if (enter_delete_mode)
- X tputs(enter_delete_mode, ONE_LINE, append_to_output_string);
- X
- X for (count = num_to_delete; count; --count)
- X tputs(delete_a_char, ONE_LINE, append_to_output_string);
- X
- X if (enter_delete_mode)
- X tputs(exit_delete_mode, ONE_LINE, append_to_output_string);
- X } else {
- X num_to_back_up = display_string_into_output_string(new_dot);
- X for (count = num_to_delete; count; --count)
- X output_string[output_string_length++] = ' ';
- X for (count = num_to_back_up + num_to_delete; count; --count)
- X tputs(cursor_left, ONE_LINE, append_to_output_string);
- X }
- X
- X if (e->universal_argument > strlen(e->dot))
- X output_string[output_string_length++] = '\07';
- X
- X strcpy(temp_str, new_dot);
- X strcpy(e->dot, temp_str);
- X e->universal_argument = 1;
- X if (e->mark >= new_dot)
- X e->mark += (old_dot - new_dot);
- X write(1, output_string, output_string_length);
- X
- X return OK;
- X}
- X
- X
- Xint
- Xfinish_editing_line(e)
- X ED_STRUCT *e;
- X{
- X
- X char *old_dot;
- X
- X e->universal_argument = 1;
- X old_dot = e->dot;
- X beginning_of_line(e);
- X e->dot = old_dot; /* necessary to preserve cursor position
- X * accross newlines */
- X return FINISHED_EDITING;
- X}
- X
- X
- Xint
- Xself_insert(e)
- X ED_STRUCT *e;
- X{
- X
- X int num_to_back_up, count;
- X char *old_dot = e->dot; /* JJD 3-89 added */
- X
- X strcpy(output_string, "");
- X output_string_length = 0;
- X
- X if (*(e->dot) == '\0') {
- X for (count = e->universal_argument; count; --count)
- X display_char_into_output_string(e->current_input_char);
- X } else {
- X if (enter_insert_mode || pre_insert_char) {
- X if (enter_insert_mode)
- X tputs(enter_insert_mode, ONE_LINE, append_to_output_string);
- X
- X for (count = e->universal_argument; count; --count) {
- X if (pre_insert_char)
- X tputs(pre_insert_char, ONE_LINE, append_to_output_string);
- X if ((e->current_input_char < 32)) {
- X output_string[output_string_length++] = '^';
- X if (post_insert_char)
- X tputs(post_insert_char, ONE_LINE,
- X append_to_output_string);
- X if (pre_insert_char)
- X tputs(pre_insert_char, ONE_LINE,
- X append_to_output_string);
- X output_string[output_string_length++] =
- X e->current_input_char + '@';
- X } else if (e->current_input_char == 127) {
- X output_string[output_string_length++] = '^';
- X if (post_insert_char)
- X tputs(post_insert_char, ONE_LINE,
- X append_to_output_string);
- X if (pre_insert_char)
- X tputs(pre_insert_char, ONE_LINE,
- X append_to_output_string);
- X output_string[output_string_length++] = '?';
- X } else
- X output_string[output_string_length++] =
- X e->current_input_char;
- X
- X if (post_insert_char)
- X tputs(post_insert_char, ONE_LINE, append_to_output_string);
- X }
- X
- X if (enter_insert_mode)
- X tputs(exit_insert_mode, ONE_LINE, append_to_output_string);
- X } else {
- X for (count = e->universal_argument; count; --count)
- X display_char_into_output_string(e->current_input_char);
- X num_to_back_up =
- X display_string_into_output_string(e->dot);
- X for (count = num_to_back_up; count; --count)
- X tputs(cursor_left, ONE_LINE, append_to_output_string);
- X }
- X }
- X
- X strcpy(temp_str, e->dot);
- X for (count = e->universal_argument; count; --count)
- X *(e->dot++) = e->current_input_char;
- X strcpy(e->dot, temp_str);
- X if (e->mark > old_dot)
- X e->mark += (e->dot - old_dot);
- X write(1, output_string, output_string_length);
- X
- X e->universal_argument = 1;
- X return OK;
- X}
- X
- X
- Xrun_program_connected_to_standard_tty(cmd)
- X char *cmd;
- X{
- X
- X int status;
- X void (*sig)();
- X
- X ioctl(0, TIOCGETP, &new_stdin);
- X ioctl(0, TIOCSETP, &old_stdin);
- X printf("Now running \"%s\"\r\n", cmd);
- X sig=signal(SIGCHLD,SIG_DFL);
- X status = system(cmd);
- X signal(SIGCHLD,sig);
- X printf("Finished running \"%s\"\r\n", cmd);
- X ioctl(0, TIOCSETP, &new_stdin);
- X write(1, "Continue: ", 10);
- X return status;
- X}
- X
- X
- Xquietly_run_program_connected_to_standard_tty(cmd)
- X char *cmd;
- X{
- X
- X int status;
- X void (*sig)();
- X
- X ioctl(0, TIOCGETP, &new_stdin);
- X ioctl(0, TIOCSETP, &old_stdin);
- X sig=signal(SIGCHLD,SIG_DFL);
- X status = system(cmd);
- X signal(SIGCHLD,sig);
- X ioctl(0, TIOCSETP, &new_stdin);
- X return status;
- X}
- X
- X
- X
- Xint
- Xuppercase_word(e)
- X ED_STRUCT *e;
- X{
- X
- X char *ch, *cb;
- X
- X cb = e->current_buffer;
- X ch = e->dot;
- X
- X if (ch != cb) /* not at beginning of buffer */
- X while ((ch >= cb) && (!isalnum(*ch)) && (*ch != '-') && (*ch != '_'))
- X ch--; /* search backwards until in a word */
- X
- X while ((ch >= cb) && (isalnum(*ch) || (*ch == '-') || (*ch == '_')))
- X ch--; /* find first letter in word */
- X
- X while (isalnum(*++ch) || (*ch == '-') || (*ch == '_'))
- X if ((*ch >= 'a') && (*ch <= 'z'))
- X *ch -= 32; /* uppercase all lowers */
- X
- X erase_current_edit_line(e);
- X draw_current_edit_line(e);
- X return OK;
- X}
- X
- Xint
- Xlowercase_word(e)
- X ED_STRUCT *e;
- X{
- X
- X char *ch, *cb;
- X
- X cb = e->current_buffer;
- X ch = e->dot;
- X
- X if (ch != cb) /* not at beginning of buffer */
- X while ((ch >= cb) && (!isalnum(*ch)) && (*ch != '-') && (*ch != '_'))
- X ch--; /* search backwards until in a word */
- X
- X while ((ch >= cb) && (isalnum(*ch) || (*ch == '-') || (*ch == '_')))
- X ch--; /* find first letter in word */
- X
- X while (isalnum(*++ch) || (*ch == '-') || (*ch == '_'))
- X if ((*ch >= 'A') && (*ch <= 'Z'))
- X *ch += 32; /* lowercase all uppers */
- X
- X erase_current_edit_line(e);
- X draw_current_edit_line(e);
- X return OK;
- X}
- X
- X
- Xint
- Xcapitalize_word(e)
- X ED_STRUCT *e;
- X{
- X
- X char *ch, *cb;
- X int subword_flag = 0;
- X
- X cb = e->current_buffer;
- X ch = e->dot;
- X
- X if (ch != cb) /* not at beginning of buffer */
- X while ((ch >= cb) && (!isalnum(*ch)) && (*ch != '-') && (*ch != '_'))
- X ch--; /* search backwards until in a word */
- X
- X while ((ch >= cb) && (isalnum(*ch) || (*ch == '-') || (*ch == '_')))
- X ch--; /* find first letter in word */
- X
- X if ((*++ch >= 'a') && (*ch <= 'z'))
- X *ch -= 32; /* uppercase first letter */
- X
- X while (isalnum(*++ch) || (*ch == '-') || (*ch == '_'))
- X if (!isalnum(*ch))
- X subword_flag = 1; /* next char starts subword */
- X else if (subword_flag) {
- X subword_flag = 0;
- X if ((*ch >= 'a') && (*ch <= 'z'))
- X *ch -= 32; /* uppercase first letter */
- X } else if ((*ch >= 'A') && (*ch <= 'Z'))
- X *ch += 32; /* lowercase subsequent letters */
- X
- X erase_current_edit_line(e);
- X draw_current_edit_line(e);
- X return OK;
- X}
- X
- Xint
- Xul_to_dash_word(e)
- X ED_STRUCT *e;
- X{
- X
- X char *ch, *cb;
- X
- X cb = e->current_buffer;
- X ch = e->dot;
- X
- X if (ch != cb) /* not at beginning of buffer */
- X while ((ch >= cb) && (!isalnum(*ch)) && (*ch != '-') && (*ch != '_'))
- X ch--; /* search backwards until in a word */
- X
- X while ((ch >= cb) && (isalnum(*ch) || (*ch == '-') || (*ch == '_')))
- X ch--; /* find first letter in word */
- X
- X while (isalnum(*++ch) || (*ch == '-') || (*ch == '_'))
- X if (*ch == '_') /* replace underscores with hyphens */
- X *ch = '-';
- X
- X erase_current_edit_line(e);
- X draw_current_edit_line(e);
- X return OK;
- X}
- X
- Xint
- Xdash_to_ul_word(e)
- X ED_STRUCT *e;
- X{
- X
- X char *ch, *cb;
- X
- X cb = e->current_buffer;
- X ch = e->dot;
- X
- X if (ch != cb) /* not at beginning of buffer */
- X while ((ch >= cb) && (!isalnum(*ch)) && (*ch != '-') && (*ch != '_'))
- X ch--; /* search backwards until in a word */
- X
- X while ((ch >= cb) && (isalnum(*ch) || (*ch == '-') || (*ch == '_')))
- X ch--; /* find first letter in word */
- X
- X while (isalnum(*++ch) || (*ch == '-') || (*ch == '_'))
- X if (*ch == '-') /* replace hyphens with underscores */
- X *ch = '_';
- X
- X erase_current_edit_line(e);
- X draw_current_edit_line(e);
- X return OK;
- X}
- X
- X
- X/*
- Xint
- Xdescribe_bindings(e)
- X ED_STRUCT *e;
- X{
- X
- X char cmd[256];
- X
- X erase_current_edit_line(e);
- X write(1, "One moment. . .", 15);
- X strcpy(cmd, "/usr/ucb/more ");
- X strcat(cmd, getenv("HOME"));
- X strcat(cmd, ".rk.key_map");
- X quietly_run_program_connected_to_standard_tty(cmd);
- X write(1, "Continue: ", 10);
- X draw_current_edit_line(e);
- X return OK;
- X}
- X*/
- X
- X
- X
- Xrun_tty_program(e)
- X ED_STRUCT *e;
- X{
- X
- X char cmd[512];
- X
- X erase_current_edit_line(e);
- X e->dot = e->current_buffer;
- X e->mark = e->current_buffer;
- X *(e->dot) = '\0';
- X
- X ioctl(0, TIOCGETP, &new_stdin);
- X ioctl(0, TIOCSETP, &old_stdin);
- X strcpy(cmd, "");
- X printf("Command to run ([RETURN] to cancel): ");
- X fflush(stdout);
- X gets(cmd);
- X if (cmd[0] == '\0') {
- X printf("Command cancelled.\r\n");
- X ioctl(0, TIOCSETP, &new_stdin);
- X } else {
- X ioctl(0, TIOCSETP, &new_stdin);
- X run_program_connected_to_standard_tty(cmd);
- X }
- X
- X return OK;
- X}
- X
- Xrun_talk(e)
- X ED_STRUCT *e;
- X{
- X
- X char cmd[256], *who_to;
- X
- X erase_current_edit_line(e);
- X e->dot = e->current_buffer;
- X e->mark = e->current_buffer;
- X *(e->dot) = '\0';
- X
- X ioctl(0, TIOCGETP, &new_stdin);
- X ioctl(0, TIOCSETP, &old_stdin);
- X strcpy(cmd, "talk ");
- X who_to = &cmd[5];
- X printf("Talk to whom ([RETURN] to cancel): ");
- X fflush(stdout);
- X gets(who_to);
- X if (who_to[0] == '\0') {
- X printf("Talk cancelled.\r\n");
- X ioctl(0, TIOCSETP, &new_stdin);
- X } else {
- X ioctl(0, TIOCSETP, &new_stdin);
- X run_program_connected_to_standard_tty(cmd);
- X }
- X
- X return OK;
- X}
- X
- Xrun_write(e)
- X ED_STRUCT *e;
- X{
- X
- X char cmd[256], *who_to;
- X
- X erase_current_edit_line(e);
- X e->dot = e->current_buffer;
- X e->mark = e->current_buffer;
- X *(e->dot) = '\0';
- X
- X ioctl(0, TIOCGETP, &new_stdin);
- X ioctl(0, TIOCSETP, &old_stdin);
- X strcpy(cmd, "write ");
- X who_to = &cmd[6];
- X printf("write to whom ([RETURN] to cancel): ");
- X fflush(stdout);
- X gets(who_to);
- X if (who_to[0] == '\0') {
- X printf("Write cancelled.\r\n");
- X ioctl(0, TIOCSETP, &new_stdin);
- X } else {
- X ioctl(0, TIOCSETP, &new_stdin);
- X run_program_connected_to_standard_tty(cmd);
- X }
- X
- X return OK;
- X}
- X
- Xrun_pp(e)
- X ED_STRUCT *e;
- X{ /* JJD 9-86 */
- X
- X char cmd[256], *who_to;
- X
- X erase_current_edit_line(e);
- X e->dot = e->current_buffer;
- X e->mark = e->current_buffer;
- X *(e->dot) = '\0';
- X
- X ioctl(0, TIOCGETP, &new_stdin);
- X ioctl(0, TIOCSETP, &old_stdin);
- X strcpy(cmd, "pp ");
- X who_to = &cmd[3];
- X printf("pp what file ([RETURN] to cancel): ");
- X fflush(stdout);
- X gets(who_to);
- X if (who_to[0] == '\0') {
- X printf("pp cancelled.\r\n");
- X ioctl(0, TIOCSETP, &new_stdin);
- X } else {
- X ioctl(0, TIOCSETP, &new_stdin);
- X run_program_connected_to_standard_tty(cmd);
- X }
- X
- X return OK;
- X}
- X
- Xrun_mesg(e)
- X ED_STRUCT *e;
- X{
- X
- X char cmd[256], *on_or_off;
- X
- X erase_current_edit_line(e);
- X e->dot = e->current_buffer;
- X e->mark = e->current_buffer;
- X *(e->dot) = '\0';
- X
- X ioctl(0, TIOCGETP, &new_stdin);
- X ioctl(0, TIOCSETP, &old_stdin);
- X strcpy(cmd, "mesg ");
- X on_or_off = &cmd[5];
- X printf("Do you want \"mesg y\" or \"mesg n\" ");
- X printf("(type y or n and press [RETURN]): ");
- X fflush(stdout);
- X gets(on_or_off);
- X if (!strncmp(on_or_off, "on", 2))
- X strcpy(on_or_off, "y");
- X else if (!strncmp(on_or_off, "off", 3))
- X strcpy(on_or_off, "n");
- X else if (*on_or_off == 'y' || *on_or_off == 'n')
- X on_or_off[1] = '\0';
- X else if (on_or_off[0] == '\0') {
- X printf("Mesg cancelled.\r\n");
- X ioctl(0, TIOCSETP, &new_stdin);
- X return OK;
- X } else {
- X printf("Mesg cancelled because you didn't respond with y or n.\r\n");
- X ioctl(0, TIOCSETP, &new_stdin);
- X return OK;
- X }
- X
- X ioctl(0, TIOCSETP, &new_stdin);
- X run_program_connected_to_standard_tty(cmd);
- X return OK;
- X}
- X
- Xint describe_arguments(e)
- X ED_STRUCT *e;
- X{
- X extern num_buffers;
- X extern char silent;
- X extern char login;
- X extern max_len;
- X extern max_eol;
- X extern char *zero_freq_file;
- X extern char *prime_file;
- X extern char *key_file;
- X
- X
- X printf("\r\nCurrent Command Line Argument Values:\r\n");
- X printf(" -b (Number of buffers) = %d\r\n", num_buffers);
- X printf(" -e (End of Line length) = %d\r\n",max_eol);
- X printf(" -f (Maximum Frequency) = %d\r\n",max_freq);
- X printf(" -i (Inline Length) = %d\r\n",max_len);
- X printf(" -k (Key Bindings File) = \"%s\"\r\n",key_file);
- X printf(" -n (Nodes to allocate) = %d\r\n",max_nodes);
- X printf(" -o (Order of model) = %d\r\n",maxk);
- X printf(" -p (Prime File) = \"%s\"\r\n",prime_file);
- X printf(" -s (Maximum to prime) = %d\r\n",maxprime);
- X printf(" -z (Zero Frequency File)= \"%s\"\r\n",zero_freq_file);
- X printf(" -A (add_space_mode) = %s\r\n",add_space_mode?"TRUE":"FALSE");
- X printf(" -E (eol_only_mode) = %s\r\n",eol_only_mode?"TRUE":"FALSE");
- X printf(" -L (eol_longer_mode) = %s\r\n",eol_longer_mode?"TRUE":"FALSE");
- X printf(" -N (nl_truncate_mode) = %s\r\n",nl_truncate_mode?"TRUE":"FALSE");
- X printf(" -P (pred_mode) = %s\r\n",pred_mode?"TRUE":"FALSE");
- X printf(" -S (show_eol_mode) = %s\r\n",show_eol_mode?"TRUE":"FALSE");
- X printf(" -g (login shell) = %s\r\n",login?"TRUE":"FALSE");
- X printf(" -l (lisp_mode) = %s\r\n",lisp_mode?"TRUE":"FALSE");
- X printf(" -m (silent startup) = %s\r\n",silent?"TRUE":"FALSE");
- X write(1, "Continue: ", 10);
- X draw_current_edit_line(e);
- X return OK;
- X}
- END_OF_FILE
- if test 35838 -ne `wc -c <'functions.c'`; then
- echo shar: \"'functions.c'\" unpacked with wrong size!
- fi
- # end of 'functions.c'
- fi
- echo shar: End of archive 4 \(of 4\).
- cp /dev/null ark4isdone
- MISSING=""
- for I in 1 2 3 4 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 4 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
-